/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utility.CustomTag;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *
 * @author chickencake1
 */
public class SexSelectorTag extends SimpleTagSupport{
    private String sex;
    public void setSex(String sex)
    {
        this.sex=sex;
    }
    private void Writeout() throws IOException            
    {
        if(sex=="")
            sex="Chọn";
        JspWriter out =getJspContext().getOut();
        String [] sexlist ={"Chọn giới tính","Nam","Nữ"};
        String [] sexlistID ={"","1","0"};
        out.println("<select name=\"sex\">");
        for(int i=0;i<sexlistID.length;i++)
        {
            if(sexlistID[i].equals(sex))
                out.println("<option selected value=\""+sex+"\" >"+sexlist[i]+"</option>");
            else
            {
                    out.println("<option value=\""+sexlistID[i]+"\">"+sexlist[i]+"</option>");
            }
        }               
    }

    @Override
    public void doTag() throws JspException, IOException {
        Writeout();
    }
    
}
